<?php
class Application_Plugin_AccessCheck extends Zend_Controller_Plugin_Abstract {
    
    private $_acl = null;
    
    public function __construct(Zend_Acl $acl) {
        $this->_acl = $acl;
    }
    
    public function preDispatch(Zend_Controller_Request_Abstract $request) {
        $resource = $request->getControllerName();
        $action = $request->getActionName();
        $alp = array();
        $alp = $request->getParams();
       # $alp->
                #getParams();
       # var_dump($alp);
       # die;
        if(!$this->_acl->isAllowed(Zend_Registry::get('role'), $resource, $action)){
            if($resource != 'index' && $action  != 'index') {
                Zend_Registry::set('afterLoginParams', $alp);
            } else {
                Zend_Registry::set('afterLoginParams', array());
            }
          #  $request->setControllerName('index')
           #         ->setActionName('index');
        }
    }
}
?>
